package com.liang.bishi.other;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 6 4
 * abcdef
 * 1 2
 * 1 4
 * 2
 * 2
 */
public class Test02 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // 字符串长度
        int q = in.nextInt(); // 操作次数
        String s = in.next(); // 初始字符串
        // 固定位标识
        int[] location = new int[n];
        for (int i = 0; i < q; i++) {
            int op = in.nextInt();
            if (op == 1) {
                // 第u位固定
                int u = in.nextInt();
                location[u - 1] = 1;
            } else if (op == 2) {
                // 移动1位
                String s1 = moveToRight(s, location);
                s = contact(s, s1, location);
            }
        }
        System.out.println(s);
    }

    // 先顺序移动，再插入固定位数字
    private static String moveToRight(String s, int[] location) {
        // 保存移动的数组
        int count = (int) Arrays.stream(location).filter(i -> i == 1).count();
        char[] chars = new char[s.length() - count];
        // 向右移动一位，跳过固定位
        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (location[i] == 0) {
                chars[index++] = s.charAt(i);
            }
        }
        s = new String(chars);
        // 向右移动一位
        for (int i = 0; i < s.length(); i++) {
            if (i == s.length() - 1) {
                chars[0] = s.charAt(i);
            } else {
                chars[i + 1] = s.charAt(i);
            }
        }
        return new String(chars);
    }

    private static String contact(String s, String s1, int[] location) {
        char[] chars = new char[s.length()];
        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (location[i] == 1) {
                // 取固定位
                chars[i] = s.charAt(i);
            } else {
                chars[i] = s1.charAt(index++);
            }
        }
        return new String(chars);
    }
}